
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 12/04/2012 16:00:04
-- Generated from EDMX file: C:\Users\LongNguyen\Desktop\[BMS]]Project\Final_Prototype_UsingDev_QuanLy_071012\DAO\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [BMS_DB];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_BILLING_COSTING_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BILLING_COSTING_INFO] DROP CONSTRAINT [FK_BILLING_COSTING_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_BOOKING_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BOOKING_INFO] DROP CONSTRAINT [FK_BOOKING_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_CUSTOMER_INFO_STAFF_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CUSTOMER_INFO] DROP CONSTRAINT [FK_CUSTOMER_INFO_STAFF_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_CUSTOMER_PARTNER_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CUSTOMER_PARTNER_INFO] DROP CONSTRAINT [FK_CUSTOMER_PARTNER_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_DEBIT_NOTE_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DEBIT_NOTE_INFO] DROP CONSTRAINT [FK_DEBIT_NOTE_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[BMS_DatabaseModelStoreContainer].[FK_MANAGED_BY_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [BMS_DatabaseModelStoreContainer].[MANAGED_BY] DROP CONSTRAINT [FK_MANAGED_BY_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_PROPOSAL_FOR_REBATE_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PROPOSAL_FOR_REBATE_INFO] DROP CONSTRAINT [FK_PROPOSAL_FOR_REBATE_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_PROVINCE/CITY_INFO_COUNTRY_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PROVINCE/CITY_INFO] DROP CONSTRAINT [FK_PROVINCE/CITY_INFO_COUNTRY_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_QUOTATION_INFO_CUSTOMER_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[QUOTATION_INFO] DROP CONSTRAINT [FK_QUOTATION_INFO_CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[FK_USER_ACCOUNT_STAFF_INFO]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[USER_ACCOUNT] DROP CONSTRAINT [FK_USER_ACCOUNT_STAFF_INFO];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[BILLING_COSTING_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BILLING_COSTING_INFO];
GO
IF OBJECT_ID(N'[dbo].[BOOKING_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BOOKING_INFO];
GO
IF OBJECT_ID(N'[dbo].[COUNTRY_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[COUNTRY_INFO];
GO
IF OBJECT_ID(N'[dbo].[CUSTOMER_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CUSTOMER_INFO];
GO
IF OBJECT_ID(N'[dbo].[CUSTOMER_PARTNER_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CUSTOMER_PARTNER_INFO];
GO
IF OBJECT_ID(N'[dbo].[DEBIT_NOTE_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DEBIT_NOTE_INFO];
GO
IF OBJECT_ID(N'[BMS_DatabaseModelStoreContainer].[MANAGED_BY]', 'U') IS NOT NULL
    DROP TABLE [BMS_DatabaseModelStoreContainer].[MANAGED_BY];
GO
IF OBJECT_ID(N'[dbo].[PROPOSAL_FOR_REBATE_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PROPOSAL_FOR_REBATE_INFO];
GO
IF OBJECT_ID(N'[dbo].[PROVINCE/CITY_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PROVINCE/CITY_INFO];
GO
IF OBJECT_ID(N'[dbo].[QUOTATION_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[QUOTATION_INFO];
GO
IF OBJECT_ID(N'[dbo].[STAFF_INFO]', 'U') IS NOT NULL
    DROP TABLE [dbo].[STAFF_INFO];
GO
IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL
    DROP TABLE [dbo].[sysdiagrams];
GO
IF OBJECT_ID(N'[dbo].[USER_ACCOUNT]', 'U') IS NOT NULL
    DROP TABLE [dbo].[USER_ACCOUNT];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'BILLING_COSTING_INFO'
CREATE TABLE [dbo].[BILLING_COSTING_INFO] (
    [BC_CODE] nchar(15)  NOT NULL,
    [BC_DATE] datetime  NOT NULL,
    [SALE_NAME] nvarchar(30)  NOT NULL,
    [HBL] char(15)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [COUNTRY] nvarchar(15)  NOT NULL,
    [PROVINCE_CITY] nvarchar(15)  NOT NULL,
    [DISTRICT] nvarchar(15)  NOT NULL,
    [ADDRESS] nvarchar(20)  NOT NULL,
    [TEL] char(20)  NULL,
    [FAX] char(20)  NULL,
    [PLACE_RECEIPT] char(20)  NOT NULL,
    [PLACE_DELIVERY] char(20)  NOT NULL,
    [CUSTOMER_PARTNER] nvarchar(40)  NOT NULL
);
GO

-- Creating table 'BOOKING_INFO'
CREATE TABLE [dbo].[BOOKING_INFO] (
    [BOOKING_CODE] char(15)  NOT NULL,
    [BOOKING_DATE] datetime  NOT NULL,
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [CUSTOMER_PARTNER] nvarchar(40)  NOT NULL,
    [PLACE_RECEIPT] char(20)  NOT NULL,
    [PORT_LOADING] char(20)  NOT NULL,
    [PLACE_DELIVERY] char(20)  NOT NULL,
    [PORT_DISCHARGE] char(20)  NOT NULL,
    [VESSEL] char(25)  NOT NULL,
    [ETD] datetime  NOT NULL,
    [ETA] datetime  NOT NULL,
    [CLOSING_TIME] datetime  NULL
);
GO

-- Creating table 'COUNTRY_INFO'
CREATE TABLE [dbo].[COUNTRY_INFO] (
    [COUNTRY_NAME] char(50)  NULL,
    [COUNTRY_CODE] char(5)  NOT NULL
);
GO

-- Creating table 'CUSTOMER_INFO'
CREATE TABLE [dbo].[CUSTOMER_INFO] (
    [STAFF_NAME] nvarchar(30)  NOT NULL,
    [COMPANY_CODE] char(5)  NOT NULL,
    [TAX_CODE] char(15)  NULL,
    [CONTACT_PERSON] nvarchar(30)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [DOMAIN] nvarchar(10)  NOT NULL,
    [COUNTRY] nvarchar(15)  NOT NULL,
    [PROVINCE_CITY] nvarchar(15)  NOT NULL,
    [DISTRICT] nvarchar(15)  NOT NULL,
    [ADDRESS] nvarchar(100)  NOT NULL,
    [MAIL] char(30)  NULL,
    [WEB] char(30)  NULL,
    [TEL] char(20)  NULL,
    [FAX] char(20)  NULL,
    [REMARK] nvarchar(50)  NULL,
    [CUSTOMER_PARTNER] nvarchar(40)  NULL,
    [QUOTA_CODE] nchar(15)  NULL,
    [BOOKING_CODE] nchar(15)  NULL,
    [DN_CODE] nchar(15)  NULL,
    [BC_CODE] nchar(15)  NULL,
    [PFR_CODE] nchar(15)  NULL,
    [MANAGED_FROM] datetime  NULL,
    [MANAGED_TO] datetime  NULL
);
GO

-- Creating table 'CUSTOMER_PARTNER_INFO'
CREATE TABLE [dbo].[CUSTOMER_PARTNER_INFO] (
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [CUSTOMER_PARTNER] nvarchar(40)  NOT NULL,
    [PARTNER_NAME] nvarchar(30)  NOT NULL,
    [DOMAIN] nvarchar(10)  NOT NULL,
    [COUNTRY] nvarchar(15)  NOT NULL,
    [PROVINCE_CITY] nvarchar(15)  NOT NULL,
    [DISTRICT] nvarchar(15)  NOT NULL,
    [ADDRESS] nvarchar(20)  NOT NULL,
    [MAIL] char(10)  NULL,
    [WEB] char(20)  NULL,
    [TEL] char(20)  NULL,
    [FAX] char(20)  NULL,
    [REMARK] nvarchar(50)  NULL
);
GO

-- Creating table 'DEBIT_NOTE_INFO'
CREATE TABLE [dbo].[DEBIT_NOTE_INFO] (
    [DN_CODE] char(15)  NOT NULL,
    [DN_DATE] datetime  NOT NULL,
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [COUNTRY] nvarchar(15)  NOT NULL,
    [PROVINCE_CITY] nvarchar(15)  NOT NULL,
    [DISTRICT] nvarchar(15)  NOT NULL,
    [ADDRESS] nvarchar(20)  NOT NULL,
    [TEL] char(20)  NULL,
    [FAX] char(20)  NULL,
    [VESSEL] char(25)  NOT NULL,
    [MBL] char(15)  NOT NULL,
    [HBL] char(15)  NOT NULL,
    [ETD] datetime  NOT NULL,
    [VOLUME] char(10)  NOT NULL,
    [QUANTITY] char(10)  NOT NULL
);
GO

-- Creating table 'MANAGED_BY'
CREATE TABLE [dbo].[MANAGED_BY] (
    [COMPANY_CODE] char(5)  NOT NULL,
    [CONTACT_PERSON] nvarchar(30)  NULL,
    [COMPANY_NAME] nvarchar(30)  NULL,
    [STAFF_NAME] nvarchar(30)  NOT NULL,
    [TEL] char(20)  NULL,
    [EMAIL] char(30)  NULL,
    [POSITION] nvarchar(30)  NULL,
    [MANAGED_FROM] datetime  NULL,
    [MANAGED_TO] datetime  NOT NULL
);
GO

-- Creating table 'PROPOSAL_FOR_REBATE_INFO'
CREATE TABLE [dbo].[PROPOSAL_FOR_REBATE_INFO] (
    [PFR_CODE] nchar(15)  NOT NULL,
    [PFR_DATE] datetime  NOT NULL,
    [HBL] char(15)  NOT NULL,
    [REMARK] nvarchar(50)  NULL,
    [PROPOSAL_STAFF] nvarchar(30)  NOT NULL,
    [WHO_PAID] nvarchar(30)  NOT NULL,
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [APPROVED_BY] nvarchar(30)  NOT NULL
);
GO

-- Creating table 'PROVINCE_CITY_INFO'
CREATE TABLE [dbo].[PROVINCE_CITY_INFO] (
    [COUNTRY_CODE] char(5)  NULL,
    [COUNTRY_NAME] char(50)  NULL,
    [PROVINCE_CITY_CODE] char(5)  NOT NULL,
    [PROVINCE_CITY_NAME] nvarchar(50)  NULL
);
GO

-- Creating table 'QUOTATION_INFO'
CREATE TABLE [dbo].[QUOTATION_INFO] (
    [QUOTA_CODE] char(15)  NOT NULL,
    [QUOTA_DATE] datetime  NOT NULL,
    [QUOTA_VALIDITY] datetime  NOT NULL,
    [CUSTOMER_CODE] char(5)  NOT NULL,
    [CUSTOMER_NAME] nvarchar(30)  NOT NULL,
    [COMPANY_NAME] nvarchar(30)  NOT NULL,
    [COUNTRY] nvarchar(15)  NOT NULL,
    [PROVINCE_CITY] nvarchar(15)  NOT NULL,
    [DISTRICT] nvarchar(15)  NOT NULL,
    [ADDRESS] nvarchar(20)  NOT NULL,
    [TEL] char(20)  NOT NULL,
    [FAX] char(20)  NOT NULL,
    [DEPARTURE] char(20)  NOT NULL,
    [DESTINATION] char(20)  NOT NULL,
    [TRANSIT_TYPE] char(5)  NOT NULL,
    [FREIGHT] char(10)  NOT NULL,
    [TRANSIT_TIME] datetime  NOT NULL
);
GO

-- Creating table 'STAFF_INFO'
CREATE TABLE [dbo].[STAFF_INFO] (
    [STAFF_CODE] nchar(10)  NOT NULL,
    [GENDER] int  NOT NULL,
    [FIRST_NAME] nvarchar(15)  NOT NULL,
    [LAST_NAME] nvarchar(15)  NOT NULL,
    [FULL_NAME_VN] nvarchar(30)  NOT NULL,
    [FULL_NAME_EN] nvarchar(30)  NOT NULL,
    [BIRTHDAY] datetime  NULL,
    [ADDRESS] nvarchar(100)  NULL,
    [TEL] char(20)  NULL,
    [EMAIL] char(30)  NULL,
    [REMARK] nvarchar(50)  NULL,
    [POSITION] nvarchar(30)  NOT NULL,
    [STAFF_NAME] nvarchar(30)  NOT NULL
);
GO

-- Creating table 'sysdiagrams'
CREATE TABLE [dbo].[sysdiagrams] (
    [name] nvarchar(128)  NOT NULL,
    [principal_id] int  NOT NULL,
    [diagram_id] int IDENTITY(1,1) NOT NULL,
    [version] int  NULL,
    [definition] varbinary(max)  NULL
);
GO

-- Creating table 'USER_ACCOUNT'
CREATE TABLE [dbo].[USER_ACCOUNT] (
    [USERNAME] nvarchar(15)  NOT NULL,
    [PASSWORD] char(10)  NOT NULL,
    [STAFF_NAME] nvarchar(30)  NOT NULL,
    [POSITION] nvarchar(30)  NOT NULL,
    [STAFF_GROUP] nchar(10)  NULL,
    [CREATIVE_DATE] datetime  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [BC_CODE] in table 'BILLING_COSTING_INFO'
ALTER TABLE [dbo].[BILLING_COSTING_INFO]
ADD CONSTRAINT [PK_BILLING_COSTING_INFO]
    PRIMARY KEY CLUSTERED ([BC_CODE] ASC);
GO

-- Creating primary key on [BOOKING_CODE] in table 'BOOKING_INFO'
ALTER TABLE [dbo].[BOOKING_INFO]
ADD CONSTRAINT [PK_BOOKING_INFO]
    PRIMARY KEY CLUSTERED ([BOOKING_CODE] ASC);
GO

-- Creating primary key on [COUNTRY_CODE] in table 'COUNTRY_INFO'
ALTER TABLE [dbo].[COUNTRY_INFO]
ADD CONSTRAINT [PK_COUNTRY_INFO]
    PRIMARY KEY CLUSTERED ([COUNTRY_CODE] ASC);
GO

-- Creating primary key on [COMPANY_CODE] in table 'CUSTOMER_INFO'
ALTER TABLE [dbo].[CUSTOMER_INFO]
ADD CONSTRAINT [PK_CUSTOMER_INFO]
    PRIMARY KEY CLUSTERED ([COMPANY_CODE] ASC);
GO

-- Creating primary key on [CUSTOMER_PARTNER] in table 'CUSTOMER_PARTNER_INFO'
ALTER TABLE [dbo].[CUSTOMER_PARTNER_INFO]
ADD CONSTRAINT [PK_CUSTOMER_PARTNER_INFO]
    PRIMARY KEY CLUSTERED ([CUSTOMER_PARTNER] ASC);
GO

-- Creating primary key on [DN_CODE] in table 'DEBIT_NOTE_INFO'
ALTER TABLE [dbo].[DEBIT_NOTE_INFO]
ADD CONSTRAINT [PK_DEBIT_NOTE_INFO]
    PRIMARY KEY CLUSTERED ([DN_CODE] ASC);
GO

-- Creating primary key on [COMPANY_CODE], [STAFF_NAME], [MANAGED_TO] in table 'MANAGED_BY'
ALTER TABLE [dbo].[MANAGED_BY]
ADD CONSTRAINT [PK_MANAGED_BY]
    PRIMARY KEY CLUSTERED ([COMPANY_CODE], [STAFF_NAME], [MANAGED_TO] ASC);
GO

-- Creating primary key on [PFR_CODE] in table 'PROPOSAL_FOR_REBATE_INFO'
ALTER TABLE [dbo].[PROPOSAL_FOR_REBATE_INFO]
ADD CONSTRAINT [PK_PROPOSAL_FOR_REBATE_INFO]
    PRIMARY KEY CLUSTERED ([PFR_CODE] ASC);
GO

-- Creating primary key on [PROVINCE_CITY_CODE] in table 'PROVINCE_CITY_INFO'
ALTER TABLE [dbo].[PROVINCE_CITY_INFO]
ADD CONSTRAINT [PK_PROVINCE_CITY_INFO]
    PRIMARY KEY CLUSTERED ([PROVINCE_CITY_CODE] ASC);
GO

-- Creating primary key on [QUOTA_CODE] in table 'QUOTATION_INFO'
ALTER TABLE [dbo].[QUOTATION_INFO]
ADD CONSTRAINT [PK_QUOTATION_INFO]
    PRIMARY KEY CLUSTERED ([QUOTA_CODE] ASC);
GO

-- Creating primary key on [STAFF_NAME] in table 'STAFF_INFO'
ALTER TABLE [dbo].[STAFF_INFO]
ADD CONSTRAINT [PK_STAFF_INFO]
    PRIMARY KEY CLUSTERED ([STAFF_NAME] ASC);
GO

-- Creating primary key on [diagram_id] in table 'sysdiagrams'
ALTER TABLE [dbo].[sysdiagrams]
ADD CONSTRAINT [PK_sysdiagrams]
    PRIMARY KEY CLUSTERED ([diagram_id] ASC);
GO

-- Creating primary key on [USERNAME] in table 'USER_ACCOUNT'
ALTER TABLE [dbo].[USER_ACCOUNT]
ADD CONSTRAINT [PK_USER_ACCOUNT]
    PRIMARY KEY CLUSTERED ([USERNAME] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [CUSTOMER_CODE] in table 'BILLING_COSTING_INFO'
ALTER TABLE [dbo].[BILLING_COSTING_INFO]
ADD CONSTRAINT [FK_BILLING_COSTING_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BILLING_COSTING_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_BILLING_COSTING_INFO_CUSTOMER_INFO]
ON [dbo].[BILLING_COSTING_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [CUSTOMER_CODE] in table 'BOOKING_INFO'
ALTER TABLE [dbo].[BOOKING_INFO]
ADD CONSTRAINT [FK_BOOKING_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BOOKING_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_BOOKING_INFO_CUSTOMER_INFO]
ON [dbo].[BOOKING_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [COUNTRY_CODE] in table 'PROVINCE_CITY_INFO'
ALTER TABLE [dbo].[PROVINCE_CITY_INFO]
ADD CONSTRAINT [FK_PROVINCE_CITY_INFO_COUNTRY_INFO]
    FOREIGN KEY ([COUNTRY_CODE])
    REFERENCES [dbo].[COUNTRY_INFO]
        ([COUNTRY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PROVINCE_CITY_INFO_COUNTRY_INFO'
CREATE INDEX [IX_FK_PROVINCE_CITY_INFO_COUNTRY_INFO]
ON [dbo].[PROVINCE_CITY_INFO]
    ([COUNTRY_CODE]);
GO

-- Creating foreign key on [STAFF_NAME] in table 'CUSTOMER_INFO'
ALTER TABLE [dbo].[CUSTOMER_INFO]
ADD CONSTRAINT [FK_CUSTOMER_INFO_STAFF_INFO]
    FOREIGN KEY ([STAFF_NAME])
    REFERENCES [dbo].[STAFF_INFO]
        ([STAFF_NAME])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CUSTOMER_INFO_STAFF_INFO'
CREATE INDEX [IX_FK_CUSTOMER_INFO_STAFF_INFO]
ON [dbo].[CUSTOMER_INFO]
    ([STAFF_NAME]);
GO

-- Creating foreign key on [CUSTOMER_CODE] in table 'CUSTOMER_PARTNER_INFO'
ALTER TABLE [dbo].[CUSTOMER_PARTNER_INFO]
ADD CONSTRAINT [FK_CUSTOMER_PARTNER_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CUSTOMER_PARTNER_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_CUSTOMER_PARTNER_INFO_CUSTOMER_INFO]
ON [dbo].[CUSTOMER_PARTNER_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [CUSTOMER_CODE] in table 'DEBIT_NOTE_INFO'
ALTER TABLE [dbo].[DEBIT_NOTE_INFO]
ADD CONSTRAINT [FK_DEBIT_NOTE_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DEBIT_NOTE_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_DEBIT_NOTE_INFO_CUSTOMER_INFO]
ON [dbo].[DEBIT_NOTE_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [COMPANY_CODE] in table 'MANAGED_BY'
ALTER TABLE [dbo].[MANAGED_BY]
ADD CONSTRAINT [FK_MANAGED_BY_CUSTOMER_INFO]
    FOREIGN KEY ([COMPANY_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [CUSTOMER_CODE] in table 'PROPOSAL_FOR_REBATE_INFO'
ALTER TABLE [dbo].[PROPOSAL_FOR_REBATE_INFO]
ADD CONSTRAINT [FK_PROPOSAL_FOR_REBATE_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PROPOSAL_FOR_REBATE_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_PROPOSAL_FOR_REBATE_INFO_CUSTOMER_INFO]
ON [dbo].[PROPOSAL_FOR_REBATE_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [CUSTOMER_CODE] in table 'QUOTATION_INFO'
ALTER TABLE [dbo].[QUOTATION_INFO]
ADD CONSTRAINT [FK_QUOTATION_INFO_CUSTOMER_INFO]
    FOREIGN KEY ([CUSTOMER_CODE])
    REFERENCES [dbo].[CUSTOMER_INFO]
        ([COMPANY_CODE])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_QUOTATION_INFO_CUSTOMER_INFO'
CREATE INDEX [IX_FK_QUOTATION_INFO_CUSTOMER_INFO]
ON [dbo].[QUOTATION_INFO]
    ([CUSTOMER_CODE]);
GO

-- Creating foreign key on [STAFF_NAME] in table 'USER_ACCOUNT'
ALTER TABLE [dbo].[USER_ACCOUNT]
ADD CONSTRAINT [FK_USER_ACCOUNT_STAFF_INFO]
    FOREIGN KEY ([STAFF_NAME])
    REFERENCES [dbo].[STAFF_INFO]
        ([STAFF_NAME])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_USER_ACCOUNT_STAFF_INFO'
CREATE INDEX [IX_FK_USER_ACCOUNT_STAFF_INFO]
ON [dbo].[USER_ACCOUNT]
    ([STAFF_NAME]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------